home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / Generic_SentryReinforcement.abl < prev    next >
Encoding:
Text File  |  2001-07-16  |  6.2 KB  |  211 lines

  1.  
  2. //------------------------------------------------------------------
  3. // NOTE: The fsm name below MUST be changed in order for the
  4. // script to be considered a unique entity!
  5.  
  6. fsm Generic_SentryReinforcement : integer;
  7.  
  8.  
  9. //------------------------------------------------------------------
  10.  
  11. // Generic_SentryReinforcement:
  12. //   Performs sentry, attacking anything that comes near.
  13. //   Once a trigger is set, goes to a predefined point and
  14. //   attacks anything within range at that point.
  15.  
  16. //------------------------------------------------------------------
  17.  
  18.  
  19.  
  20. //------------------------------------------------------------------
  21. //     Constants
  22. //------------------------------------------------------------------
  23.  
  24.     const
  25.         #include_ <content\ABLScripts\mwconst.abi>
  26.  
  27. //------------------------------------------------------------------
  28. //     Types
  29. //------------------------------------------------------------------
  30.  
  31.     type
  32.         #include_ <content\ABLScripts\mwtype.abi>
  33.     
  34.  
  35. //------------------------------------------------------------------
  36. //     Variables
  37. //------------------------------------------------------------------
  38.  
  39.     var
  40.     static integer            attackRange1;        // At what range do I start shooting when I'm attacking?
  41.     static integer            withdrawRange1;        // At what range do I give up?
  42.     static integer            attackRange2;        // At what range do I start shooting (as a reinforcement)?
  43.     static integer            withdrawRange2;        // At what range do I stop shooting (as a reinforcement)?
  44.     static integer            triggerID;            // The index of my global trigger
  45.     static LocPoint            destination;        // The destination to move to when ready
  46.                                                                 
  47.     static integer            piloting;            // Piloting skill
  48.     static integer            gunnery;            // Gunnery skill/chance to hit
  49.     static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  50.     static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  51.     static integer             speed;                // What speed so I move at?
  52.     static integer             elitelevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  53.                                                 // and other things.  It indicates a general level of combat experience.
  54.     static integer            attackThrottle;        // My attack throttle
  55.     static integer            findTypes;            // What kind of enemies to look for
  56.  
  57.      static integer            isshotradius;        // How far away from me will I detect an enemy shot?
  58.  
  59.     static integer             attackSound;        // The attack sound I play when I first attack
  60.     static integer             deathSound;            // The sound I play when I die
  61.  
  62.     static integer            mood;                // My default mood.
  63.  
  64.     static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  65.  
  66. //------------------------------------------------------------------
  67. //     Init: my initialization function
  68. //------------------------------------------------------------------
  69.  
  70. function Init;
  71.     code
  72.         // script-specific variables
  73.         attackRange1    = 500;
  74.         withdrawRange1    = attackRange1 * 3 / 2;
  75.         attackRange2    = 500;
  76.         withdrawRange2    = attackRange2 * 3 / 2;
  77.         triggerID        = 1;
  78.         destination[0]    = -1;
  79.         destination[1]    = -1;
  80.         destination[2]    = -1;
  81.         takeOffDistance    = 150; 
  82.  
  83.         // driver settings
  84.         piloting        = 50;
  85.         gunnery            = 30;
  86.         minDelay        = 1.5;
  87.         maxDelay        = 3.0;
  88.         elitelevel        = 30;
  89.         attackThrottle    = 80;
  90.         speed            = 600;
  91.         isshotradius    = 80;
  92.         attackSound        = -1; // no sound
  93.         deathSound        = -1; // no sound
  94.         mood            = NEUTRAL_START;
  95.         findTypes        = FT_DEFAULT;
  96.  
  97. endfunction;
  98.  
  99. //------------------------------------------------------------------
  100. //    StartState: my initial state
  101. //------------------------------------------------------------------
  102.  
  103. state StartState;
  104.  
  105.     code
  106.         SetFiringDelay            (ME,minDelay,maxDelay);
  107.         SetIgnoreFriendlyFire    (ME,true);
  108.         SetIsShotRadius            (ME,isShotRadius);
  109.         SetEntropyMood            (ME,mood);
  110.         SetCurMood                (ME,mood);
  111.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  112.         SetAttackThrottle        (ME,attackThrottle);
  113.                 
  114.         if (orderTakeOff(takeOffDistance) == true) then
  115.             trans WaitState;
  116.         endif;
  117.  
  118. endstate;
  119.  
  120. //------------------------------------------------------------------
  121. //    WaitState: wait something to happen (my original state)
  122. //------------------------------------------------------------------
  123.  
  124. state WaitState;
  125.     code
  126.         if (GetGlobalTrigger(triggerID)) then
  127.             trans MoveToPointState;
  128.         endif;
  129.  
  130.         if (FindEnemy(attackRange1,findTypes)) then
  131.             trans Attack1State;
  132.         endif;
  133.  
  134.         OrderMoveLookOut;
  135.  
  136. endstate;
  137.  
  138. //------------------------------------------------------------------
  139. //    Attack1State: attack someone (before I'm called as a reinforcement)
  140. //------------------------------------------------------------------
  141.  
  142. state Attack1State;
  143.     code
  144.         if (LeaveAttackState(withdrawRange1)) then
  145.             trans WaitState;
  146.         endif;
  147.  
  148.         if (GetGlobalTrigger(triggerID)) then
  149.             trans Attack2State;
  150.         endif;
  151.  
  152.         if (attackSound <> -1) then    
  153.             PlaySoundOnce(attackSound);
  154.         endif;
  155.  
  156.         OrderAttack(TRUE);
  157.  
  158. endstate;
  159.  
  160. //------------------------------------------------------------------
  161. //    MoveToPointState: go to the destination, and attack when we get there
  162. //------------------------------------------------------------------
  163.  
  164. state MoveToPointState;
  165.     code
  166.         if (OrderMoveToLocPoint(destination,speed,true,true)) then
  167.             OrderStopAttacking;
  168.  
  169.             if (FindEnemy(attackRange2,findTypes)) then
  170.                 trans Attack2State;
  171.             endif;
  172.         endif;
  173.  
  174. endstate;
  175.  
  176. //------------------------------------------------------------------
  177. //    Attack2State: attack a target (after I'm called as a reinforcement)
  178. //------------------------------------------------------------------
  179.  
  180. state Attack2State;
  181.     code
  182.         if (LeaveAttackState(withdrawRange2)) then
  183.             trans MoveToPointState;
  184.         endif;
  185.  
  186.         if (attackSound <> -1) then    
  187.             PlaySoundOnce(attackSound);
  188.         endif;
  189.  
  190.         OrderAttack(TRUE);
  191.  
  192. endstate;
  193.  
  194. //------------------------------------------------------------------
  195. //    DeadState: OK, I kicked the bucket.
  196. //------------------------------------------------------------------
  197.  
  198. state DeadState;
  199.   code
  200.         if (deathSound <> -1) then    
  201.             PlaySoundOnce(deathSound);
  202.         endif;        
  203.  
  204.         orderDie;
  205.  
  206. endstate;
  207.  
  208.  
  209. endfsm.
  210.  
  211.